package io.renren.modules.jxgkphone.service.Impl;


import io.renren.modules.jxgkphone.dao.StudentSignInDao;
import io.renren.modules.jxgkphone.entity.ClassAttendance;
import io.renren.modules.jxgkphone.service.StudentSignInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class StudentSignInServiceImpl implements StudentSignInService {

    @Autowired
    StudentSignInDao studentSignInDao;
    @Override
    public ClassAttendance getMySignIn(String classCourseId, String username) {
        return studentSignInDao.getMySignIn( classCourseId, username );
    }

    @Override
    public ClassAttendance saveSginIn(Map<String, Object> params) {
        String classCourseId= (String) params.get("classCourseId");
        String username= (String) params.get("username");
        ClassAttendance classAttendance=studentSignInDao.getMySignIn( classCourseId, username );
        if(classAttendance==null){
            studentSignInDao.insertSginIn(params);
        }else {
            studentSignInDao.updateSginIn(params);
        }
         classAttendance=studentSignInDao.getMySignIn( classCourseId, username );
        return classAttendance;
    }
}
